#ifndef FTMESSAGEBOX_H
#define FTMESSAGEBOX_H

#include <QtGui>
#include "ftcontrols.h"
#include "rotatingdialog.h"

class FTLabel;
class FTPushButton;
class FTLineEdit;
class FTColorDialog;
class FTTextArea;

class FTMessageBox : public RotatingDialog
{
    Q_OBJECT

private:
    enum type { msg_error,
                msg_info,
                msg_yesno,
                msg_3question,
                msg_color,
                msg_input,
                msg_progress };

    explicit FTMessageBox(FTMessageBox::type,
                          const QString& title,
                          const QString& msg,
                          const QString& button1 = "",
                          const QString& button2 = "",
                          const QString& button3 = "",
                          const QColor& col = QColor());

    void buildCommon(const QString& title,
                     const QString& msg,
                     const QString& btn1,
                     const QString& btn2,
                     const QString& btn3,
                     const QString& icon);

    // needed data
    FTMessageBox::type msgType;

    // Common widgets
    FTLabel* msg_title;
    FTTextArea* message;
    FTPushButton* button1;
    FTPushButton* button2;
    FTPushButton* button3;
    QImage msg_icon;
    QButtonGroup buttons;

    // Other widgets for specific boxes;
    FTLineEdit* msg_input_line;
    FTColorDialog* msg_color_dialog;
    QProgressBar* msg_progress_bar;

    QLayout* createHorizontal();
    QLayout* createVertical();

private slots:
    void buttonSelected(int);

public slots:
    void updateProgress(qint64,qint64);
    void updateProgress(qint64);

public:
    ~FTMessageBox();

    void paintEvent(QPaintEvent *);

    static QColor Color(const QString& title,
                        const QString& msg,
                        const QColor& c);

    static void Info(const QString& title,
                     const QString& msg,
                     const QString& ok = "");

    static void Error(const QString& title,
                      const QString& msg,
                      const QString& ok = "");

    static bool Yesno(const QString& title,
                     const QString& msg,
                     const QString& ok = "",
                     const QString& ko = "");

    static int Question(const QString& title,
                        const QString& msg,
                        const QString& a,
                        const QString& b,
                        const QString& c);

    static QString TextInput(const QString& title,
                             const QString& msg,
                             const QString& def = "");

    static FTMessageBox* Progress( const QString& title,
                         const QString& msg,
                         int min = 0, int max = 100 );
};

#endif // FTMESSAGEBOX_H
